<?php
if(isset($_POST["submit"]) == '')
{
	$intro->setid($_GET["id"]);
	$detail = $intro->getone();
?>

<div id="content_wrapper">
<div id="main_content" class="cf">
<form action="" class="formEl" id="form_a" method="post" enctype="multipart/form-data">
<div class="cf sepH_c">
<div id="content_actions" class="fr">
<button class="fr next btn btn_d submitForm" name="submit" type="submit" value="Submit">Sửa</button>
<a href="javascript:void(0)" class="clear_form btn btn_a">Clear form</a>
<a href="javascript:history.go(-1)" class="btn btn_a">Cancel</a></div>

</div>

<ul class="tabsB cf">
	<li><a href="#tab-1">Sửa nội dung slide</a></li>
	
</ul>

<div class="msg_box msg_error" id="form_a_errors" style="display: none"></div>

<div class="content_panes">

<div id="tab-1">

<div class="formEl_a">

<fieldset><legend>Thông tin slide</legend>
    <div class="sepH_b"><label for="title" class="lbl_a">Tiêu đề</label> 
    <input	type="hidden" name="location" value="<?=$detail["location"]?>" />
        <input	type="text" id="title" name="title" class="inpt_a" value="<?=$detail["title"]?>" />
    </div>

	<div class="sepH_c cf"><label for="link" class="lbl_a">Đường dẫn</label> 
        <input	type="text" id="link" name="link" class="inpt_a" value="<?=$detail["link"]?>" />
    </div>
	
    <div class="sepH_c cf"><label for="order" class="lbl_a">Thứ tự</label> 
        <input	type="text" id="order" name="order" class="inpt_a" value="<?=$detail["order"]?>" />
    </div>
    <div class="sepH_c"><label class="lbl_a">Ảnh slide (Chú ý: kích thước chuẩn hoặc có tỷ lệ tương đương: <?=($detail["location"] == 1)?"660px x 342px":"90px x 120px"  ?>)</label>
<div class="lblSpace">
<div><input type="file" name="img" id="upload" /></div>
</div>
	</div>
	<div class="sepH_c cf"><label for="text" class="lbl_a">Mô tả</label> <textarea	name="description" id="text" cols="30" rows="10"
	class="txtar_a"><?=$detail["description"]?></textarea></div>
</fieldset>

</div>
</div>
<div id="tab-2" class="cf formEl_a">
<div class="sepH_b cf">
<div class="dp100">


</fieldset>

</div>
</div>

</div>

</div>
</form>
</div>
</div>
<?php
} else {
	$intro->setid($_GET["id"]);
	$intro->settitle($_POST["title"]);
	$intro->setdescription($_POST["description"]);
	$intro->setlink($_POST["link"]);
	$intro->setorder($_POST["order"]);
	if ($_POST["location"] == 1){
		$img_x = "660";
		if ($_FILES["img"]["name"] != '') $intro->setimg($main->upimg($_FILES["img"], "../uploads/intro/",$img_x));
	}
	else {
		$img_x = "90";
		if ($_FILES["img"]["name"] != '') $intro->setimg($main->imgnotext($_FILES["img"], "../uploads/intro/",$img_x));		
	}
	$msg = $intro->update();
	$main->redirect("index.php?m=".$_GET["m"]."&location=".$_POST["location"]);
}
?>
<link rel="stylesheet" href="lib/elfinder/css/elfinder.full.css"
	type="text/css" />
<link rel="stylesheet" href="lib/fancybox/jquery.fancybox-1.3.4.css"
	type="text/css" />
<link rel="stylesheet" href="lib/file-uploader/fileuploader.css"
	type="text/css" />

<script type="text/javascript">
		head.js(
			"js/jquery-1.6.2.min.js",
			"lib/jquery-ui/jquery-ui-1.8.15.custom.min.js",
			"lib/harvesthq-chosen/chosen.jquery.min.js",
			"lib/fusion-charts/FusionCharts.js",
			"lib/fancybox/jquery.easing-1.3.pack.js",
			"lib/fancybox/jquery.fancybox-1.3.4.pack.js",
			"lib/tiny-mce/jquery.tinymce.js",
			"js/jquery.microaccordion.js",
			"js/jquery.tools.min.js",
			"js/jquery.stickyPanel.js",
			"js/xbreadcrumbs.js",
			"lib/jquery-validation/jquery.validate.js",
			"js/lagu.js",
			function(){
				lga_fusionCharts.chart_k();
				lga_flowTabs.tabs_b();
				lga_selectBox.init();
				lga_datepicker.init();
				lga_editor.init();
				lga_sticky.sticky_contentActions();
				lga_clearForm.init();			
				lga_form_a_validation.init();
			}
		)
    </script>
